package com.hang.config;

import com.hang.interceptor.JWTInterceptor;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class FilterConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new JWTInterceptor())
                .excludePathPatterns("/swagger-resources/**", "/webjars/**", "/v2/**","/swagger-ui.html/**")
                .excludePathPatterns("/login/**")  // 放行的请求路径
                .excludePathPatterns("/admin/**")
                .addPathPatterns("/**"); // 拦截所有请求路径除了上面放行的
    }

}